home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / grafik / gif386 / setbank.asm < prev    next >
Encoding:
Assembly Source File  |  1989-12-03  |  1.6 KB  |  123 lines

  1. ; function to select banks on popular video cards
  2. ;
  3. ; void SetBank(int device,int bank)
  4. ;
  5.  
  6. Device        EQU    dword ptr [ebp+8]
  7. Bank        EQU    word ptr [ebp+12]
  8. TSENG        EQU    0
  9. VIDEO7        EQU    1
  10. PARADISE    EQU    2
  11.  
  12.     ASSUME    ds:dseg,cs:cseg
  13.     
  14. dseg    SEGMENT    
  15. curbk    DB    0
  16. dseg    ends
  17.     
  18. cseg    SEGMENT    dword public 'CODE'
  19.     public    setbank
  20.     db    'setbank',7
  21. setbank    proc    near        ;64k bank number is in AX
  22.     push    ebp
  23.     mov    ebp,esp
  24.     push     esi
  25.     push    edi
  26.  
  27.     mov    ax,Bank
  28.     push    ax
  29.     push    dx
  30.     cli
  31.     mov    curbk,al
  32.     cmp    Device,TSENG
  33.     jnz    nots
  34.     and    al,7        ;Tseng
  35.     mov    ah,al
  36.     shl    ah,1
  37.     shl    ah,1
  38.     shl    ah,1
  39.     or    al,ah
  40.     or    al,01000000b
  41.     mov    dx,3cdh
  42.     out    dx,al
  43.     sti
  44.     pop    dx
  45.     pop    ax
  46.     pop    edi
  47.     pop    esi
  48.     mov    esp,ebp
  49.     pop    ebp
  50.     ret
  51.  
  52. nots:    cmp    Device,VIDEO7
  53.     jnz    nov7
  54.     and    ax,15        ;Video 7
  55.     push    cx
  56.     mov    ch,al
  57.     mov    dx,3c4h
  58.     mov    ax,0ea06h
  59.     out    dx,ax
  60.     mov    ah,ch
  61.     and    ah,1
  62.     mov    al,0f9h
  63.     out    dx,ax
  64.     mov    al,ch
  65.     and    al,1100b
  66.     mov    ah,al
  67.     shr    ah,1
  68.     shr    ah,1
  69.     or    ah,al
  70.     mov    al,0f6h
  71.     out    dx,al
  72.     inc    dx
  73.     in    al,dx
  74.     dec    dx
  75.     and    al,not 1111b
  76.     or    ah,al
  77.     mov    al,0f6h
  78.     out    dx,ax
  79.     mov    ah,ch
  80.     mov    cl,4
  81.     shl    ah,cl
  82.     and    ah,100000b
  83.     mov    dl,0cch
  84.     in    al,dx
  85.     mov    dl,0c2h
  86.     and    al,not 100000b
  87.     or    al,ah
  88.     out    dx,al
  89.     sti
  90.     pop    cx
  91.     pop    dx
  92.     pop    ax
  93.     pop    edi
  94.     pop    esi
  95.     mov    esp,ebp
  96.     pop    ebp    
  97.     ret
  98.     
  99. nov7:    cmp    Device,PARADISE
  100.     jnz    nopd
  101.     mov    dx,3ceh        ;Paradise
  102.     mov    ax,50fh        ;turn off write protect on VGA registers
  103.     out    dx,ax
  104.     mov    ah,curbk
  105.     shl    ah,1
  106.     shl    ah,1
  107.     shl    ah,1
  108.     shl    ah,1
  109.     mov    al,9
  110.     out    dx,ax
  111.  
  112. nopd:    sti
  113.     pop    dx
  114.     pop    ax
  115.     pop    edi
  116.     pop    esi
  117.     mov    esp,ebp
  118.     pop    ebp    
  119.     ret
  120. setbank    endp
  121. cseg    ends
  122.     end
  123.